package cn.com.nes.site.action.inventory;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.nes.common.util.DBUtils;
import cn.com.nes.site.entity.DataReq;
import cn.com.nes.site.entity.DataRes;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.module.service.inventory.InventoryService;

@Controller("inventory")
@RequestMapping("/inventory")
public class InventoryAction  {
	@Resource
    private InventoryService service;
	
//	//修改库存
//    @RequestMapping(method = RequestMethod.POST, value = "/changeInventory")
//    public @ResponseBody
//    PageData changeInventory(HttpServletRequest request,
//                      HttpServletResponse response, ModelMap modelMap) throws Exception {
//        DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
//        PageData res = new PageData() ;
//        if (req_Status.getRetCode() != 0) {
//            res = new PageData();
//            res.setRetCode(req_Status.getRetCode()) ;
//            res.setRetMessage(req_Status.getRetMessage());
//            return res;
//        }
//        DataReq req = req_Status.getReq() ;
//        res = service.changeInventory(req) ;
//        return res;
//    }
//	//查询当前库存
    @RequestMapping(method = RequestMethod.POST, value = "/CheckWarehouseNum")
    public @ResponseBody
    PageData CheckWarehouseNum(HttpServletRequest request,
                      HttpServletResponse response, ModelMap modelMap) throws Exception {
        DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
        PageData res = new PageData() ;
        if (req_Status.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(req_Status.getRetCode()) ;
            res.setRetMessage(req_Status.getRetMessage());
            return res;
        }
        DataReq req = req_Status.getReq() ;
        res = service.CheckWarehouseNum(req) ;
        return res;
    }
	//定时汇总
    @RequestMapping(method = RequestMethod.POST, value = "/inventorySummary")
    public @ResponseBody
    PageData inventorySummary(HttpServletRequest request,
                      HttpServletResponse response, ModelMap modelMap) throws Exception {
        DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
        PageData res = new PageData() ;
        if (req_Status.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(req_Status.getRetCode()) ;
            res.setRetMessage(req_Status.getRetMessage());
            return res;
        }
        DataReq req = req_Status.getReq() ;
        res = service.inventorySummary() ;
        return res;
    }
}
